<!DOCTYPE html>
<html lang="en">
<!--
  @authror litong
-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>XXX系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--引入需要的css文件-->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/ace.min.css">
<link rel="stylesheet" type="text/css" href="css/ace-rtl.min.css">
<link rel="stylesheet" type="text/css" href="css/sweetalert.css">

<style type="text/css">
.error {
  border-color: #dd4b39;
  color: #dd4b39;
}
</style>
</head>

<body class="login-layout" style="">

<div class="main-container">
  <div class="main-content">
    <div class="row">
      <div class="col-sm-10 col-sm-offset-1">
        <div class="login-container">
          <div class="center">
            <h1>
                  <span class="white">XXX系统</span>
                </h1>
          </div>

          <div class="space-6"></div>

          <div class="position-relative">
            <div class="login-box visible widget-box no-border">
              <div class="widget-body">
                <div class="widget-main">
                  <h4 class="header blue lighter bigger">
                        <i class="icon-coffee green"></i>
                        系统登录
                      </h4>

                  <div class="space-6"></div>

                  <fieldset>
                    <form id="loginbox" method="post" action="http://47.92.170.145/login" novalidate="novalidate">
                      <label class="block clearfix">
                            <span class="block input-icon input-icon-right">
                              <input id="loginId" name="loginId" type="text" class="form-control" placeholder="用户名">
                              <i class="icon-user"></i>
                            </span>
                          </label>

                      <label class="block clearfix">
                            <span class="block input-icon input-icon-right">
                              <input id="password" name="password" type="password" class="form-control" placeholder="密码">
                              <i class="icon-lock"></i>
                            </span>
                          </label>

                      <div class="space"></div>

                      <div class="clearfix">

                        <button type="submit" class="width-35 pull-right btn btn-sm btn-primary">
                              <i class="icon-key"></i>
                              登录
                            </button>
                      </div>

                      <div class="space-4"></div>
                    </form>
                  </fieldset>

                </div>
                <!-- /widget-main -->

              </div>
              <!-- /widget-body -->
            </div>
            <!-- /login-box -->

          </div>
          <!-- /position-relative -->
        </div>
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </div>
</div>
<!-- /.main-container -->
<!--引入css文件-->
<script src="js/jquery-2.0.3.min.js"></script>

<script src="js/jquery.validate.min.js"></script>
<script src="js/sweetalert.min.js"></script>

<script type="text/javascript">
$("#loginbox").validate({
  rules: {
    loginId: {
      required: true,
      minlength: 2
    },
    password: {
      required: true,
      minlength: 4
    }
  },
  messages: {
    loginId: {
      required: "请输入用户名",
      minlength: "用户名长度不能小于2位"
    },
    password: {
      required: "请输入密码",
      minlength: "密码长度不能小于4位"
    }
  },
  errorClass: "error",
  success: "success",
  errorPlacement: function(error, element) {
    error.appendTo(element.parent());
  },
  submitHandler: function(form) {
    $.post("/api/manager/login", $(form).serialize(), function(result) {
      if(result.status == 200) {
        location.href = "/manage";
      } else {
        swal({
          title: "错误信息",
          text: result.message,
          type: "error",
          confirmButtonColor: "#DD6B55"
        });
      }
    });
  }
});
</script>
</body>

</html>